package com.mtask.web.service.impl;

import com.mtask.common.dto.vo.SystemConfVo;
import com.mtask.web.repository.SysConfigRepository;
import com.mtask.web.service.HomeService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class HomeServiceImpl implements HomeService {
    @Resource
    private SysConfigRepository sysConfigRepository;


    @Override
    public List<SystemConfVo> getAllSystemConfig() {
        return SystemConfVo.fromEntities(sysConfigRepository.findAll());
    }

    @Override
    public SystemConfVo addSystemConfig() {
        return SystemConfVo.fromEntity(
                sysConfigRepository.save(
                        SystemConfVo.toEntity(SystemConfVo.builder().key("test1").value("test1").build())
                )
        );
    }

}
